<template>
<!--  <div class="index-container">-->
  <el-container>
    <el-header>
      <div class="title">
        管理系统
      </div>
      <div class="personal">
        <el-dropdown  @command="handleCommand">
      <span class="el-dropdown-link">
       <!-- <img class="head-pic" :src="userInfo" alt="">-->
       {{userInfo.userName}}<i class="el-icon-arrow-down el-icon--right"></i>
      </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="2">退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-header>
    <el-container>
      <el-aside width="260px">
        <el-menu
          class="el-menu-vertical-demo"
          :default-active="onRoutes"
          @open="handleOpen"
          @close="handleClose"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          router>
          <el-menu-item index="/manage/home">
            <i class="el-icon-menu"></i>
            <span slot="title">统计</span>
          </el-menu-item>
          <el-menu-item index="/manage/staff">
            <i class="icon-yuangongguanli1 iconfont"></i>
            <span>员工管理</span>
          </el-menu-item>
          <el-menu-item index="/manage/client">
            <i class="icon-kehuguanli iconfont"></i>
            <span>客户管理</span>
          </el-menu-item>
          <el-menu-item index="/manage/project">
            <i class="icon-xiangmuguanli iconfont"></i>
            <span>项目管理</span>
          </el-menu-item>
          <el-menu-item index="/manage/tags">
            <i class="icon-Shapecopy iconfont"></i>
            <span>标签管理</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <transition name="slide-left">
          <router-view class="child-view"/>
        </transition>
      </el-main>
    </el-container>
  </el-container>
<!--  </div>-->
</template>

<script>
import apiDataFilter from "../../utils/apiDataFilter";
import Cookies from 'js-cookie'
export default {
  name: 'index',
  data () {
    return {
      userInfo:{}
    }
  },
  computed: {
    // 首次进入页面时展开当前页面所属的菜单
    onRoutes () {
      return this.$route.path
    }
  },
  methods: {
    handleOpen (key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose (key, keyPath) {
      console.log(key, keyPath)
    },
    getUser(){
      apiDataFilter.request({
        apiPath:'member.userInfo',
        successCallback:(res)=>{
         this.userInfo = res.data;
        }
      })
    },
    handleCommand(command){
      if (command == 2){
        Cookies.remove('Authorization');
        this.$router.push('/login')
      }
    },
  },
  created () {
    this.getUser();
    console.log('hdjaskdjas')
  }
}
</script>

<style scoped lang='less'>
    @import "index.less";
</style>
